package io;

import java.io.BufferedWriter;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.util.ArrayList;
import java.util.List;

public class CreateRandomArray {

	public static void createFile(int size, String name) {
		List<Integer> input = create(size);
		try {
			BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(name), "utf-8"));
			for (int i = 0; i < input.size(); i++) {
				bw.write(input.get(i).toString() + "\n");
			}
			bw.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	private static ArrayList<Integer> create(int size) {
		ArrayList<Integer> result = new ArrayList<Integer>();
		for (int i = 0; i < size; i++) {
			result.add((int) (Math.random() * size));
		}
		return result;
	}
}
